/*
 * Unit test for function isGameOver in dominion.c
 *
 * unittest1: unittest1.c dominion.o rngs.o
 *     gcc -o unittest1 -g  unittest1.c dominion.o rngs.o $(CFLAGS)
 */

#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"

int main() {
    int seed = 1000;
    int numPlayer = 2;
    int check;
    int k[10] = {adventurer, council_room, feast, gardens, mine
               , remodel, smithy, village, baron, great_hall};
    struct gameState G;

    printf ("TESTING isGameOver():\n");
    memset(&G, 23, sizeof(struct gameState));   // clear the game state
    initializeGame(numPlayer, k, seed, &G); // initialize a new game

    // Test case 1: when province supply is empty
    //printf("Test case where province supply is empty.\n");
	G.supplyCount[province] = 0;
    check = isGameOver(&G);
    //printf("The result should be equal to 1 = %d\n", check);
	assert(check == 1);

	// Test case 2: when three supply piles are zero
	//printf("Test case where 3 supply piles are zero.\n");
	G.supplyCount[province] = 8; //reset the number of province cards
    G.supplyCount[remodel] = 0;  //
    G.supplyCount[smithy] = 0;   //
    G.supplyCount[village] = 0;  //
    check = isGameOver(&G);
    //printf("The result should be equal to 1 = %d\n", check);
	assert(check == 1);

    // Test case 3: when game over conditions are not met
    //printf("Test case where game over conditions are not met.\n");
    G.supplyCount[remodel] = 10;  //
    G.supplyCount[smithy] = 10;   //
    G.supplyCount[village] = 10;  //
    check = isGameOver(&G);
    //printf("The result should be equal to 0 = %d\n", check);
    printf("All tests passed!\n");

    return 0;
}
